package com.zpself.module.面试草搞;

import org.junit.Test;

/**
 * @author By ZengPeng
 * @Description
 * @date in  2021/4/8 10:34
 * @Modified By
 */
public class Tree {


    @Test
    public  void tre(){
        int[] arr = new int[]{1,5,2,5,11,78,323,2,1};
        for (int i :  maopao(arr)) {
            System.out.print(i+",");
        }
    }

    private int[] maopao(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j]>arr[j+1]){
                    arr[j] = arr[j]^arr[j+1];
                    arr[j+1] = arr[j]^arr[j+1];
                    arr[j] = arr[j]^arr[j+1];
                }
            }
        }
        return arr;
    }
}
